import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:ichinesereader/controller/schooladmin.dart';

import '../../themes/appTheme.dart';

class ChooseAssignmentTypeDialog extends StatefulWidget {
  ChooseAssignmentTypeDialog({
    Key? key,
  }) : super(key: key);

  _ChooseAssignmentTypeDialogState createState() =>
      new _ChooseAssignmentTypeDialogState();
}

class _ChooseAssignmentTypeDialogState
    extends State<ChooseAssignmentTypeDialog> {
  final SchoolAdminController _schoolAdminController = Get.find();

  @override
  Widget build(BuildContext context) {
    return AlertDialog(
      title: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [
          Text(
            'Homework From:'.tr,
            style: TextStyle(
                fontSize: 30.0,
                decoration: TextDecoration.underline,
                decorationStyle: TextDecorationStyle.dotted),
          ),
          InkWell(
            onTap: () {
              Navigator.of(context).pop();
            },
            child: Icon(Icons.cancel,
                color: Get.isDarkMode ? Colors.white : Colors.blueGrey),
          ),
        ],
      ),
      titleTextStyle: TextStyle(
          letterSpacing: 1,
          color: Get.isDarkMode ? Get.theme.primaryColorDark : Colors.blueGrey,
          fontSize: 20),
      backgroundColor:
          Get.isDarkMode ? AppTheme.colors.darkTheme2 : Colors.white,
      shape: RoundedRectangleBorder(
        borderRadius: BorderRadius.all(
          Radius.circular(6.0),
        ),
      ),
      content: Container(
        height: 300,
        width: 450,
        child: Column(
          children: [
            Column(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                Container(
                  width: 300.0,
                  height: 60.0,
                  child: Obx(() {
                    if (_schoolAdminController.currentClassPrograms.value.id !=
                        null) {
                      var programName = _schoolAdminController
                          .currentClassPrograms.value.name
                          .toString();

                      if (programName == 'K-2' ||
                          programName == '3-5' ||
                          programName == '6-8') {
                        return MaterialButton(
                          textColor: Get.isDarkMode
                              ? Colors.black
                              : Get.theme.primaryColorLight,
                          color: Get.isDarkMode
                              ? Get.theme.primaryColorDark
                              : Get.theme.primaryColor,
                          onPressed: () {
                            Get.toNamed('/teacher/corematerials');
                          },
                          child: Text(
                            'Core Materials'.tr,
                            style: TextStyle(fontSize: 18.0),
                          ),
                        );
                      } else {
                        return MaterialButton(
                          onPressed: () {
                            Get.toNamed('/teacher/themedbooks');
                          },
                          child: Text(
                            'Core Materials'.tr,
                            style: TextStyle(fontSize: 18.0),
                          ),
                        );
                      }
                    } else {
                      return Text('');
                    }
                  }),
                ),
                Container(
                  width: 300.0,
                  height: 60.0,
                  margin: EdgeInsets.symmetric(vertical: 12.0),
                  child: MaterialButton(
                    textColor: Get.isDarkMode
                        ? Colors.black
                        : Get.theme.primaryColorLight,
                    color: Get.isDarkMode
                        ? Get.theme.primaryColorDark
                        : Get.theme.primaryColor,
                    onPressed: () {
                      Get.offAndToNamed('/teacher/lessonplans');
                    },
                    child: Text(
                      'Lesson Plans'.tr,
                      style: TextStyle(fontSize: 18.0),
                    ),
                  ),
                ),
                Container(
                  width: 300.0,
                  height: 60.0,
                  child: MaterialButton(
                    textColor: Get.isDarkMode
                        ? Colors.black
                        : Get.theme.primaryColorLight,
                    color: Get.isDarkMode
                        ? Get.theme.primaryColorDark
                        : Get.theme.primaryColor,
                    onPressed: () {
                      Get.offAndToNamed('/teacher/library');
                    },
                    child: Text(
                      'Library'.tr,
                      style: TextStyle(fontSize: 18.0),
                    ),
                  ),
                ),
              ],
            ),
          ],
        ),
      ),
    );
  }
}
